<template>
  <div class="home">
    <!-- 二级路由 占位符 -->
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive" />
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>

    <van-tabbar v-model="active" route>
      <van-tabbar-item replace name="community" to="/home/community">
        <span>社区</span>
        <template #icon="props">
          <img
            :src="
              props.active ? community_icon.active : community_icon.inactive
            "
          />
        </template>
      </van-tabbar-item>
      <van-tabbar-item replace name="shopping" to="/home/shopping">
        <span>商城</span>
        <template #icon="props">
          <img
            :src="props.active ? shopping_icon.active : shopping_icon.inactive"
          />
        </template>
      </van-tabbar-item>
      <van-tabbar-item replace name="car" to="/home/car">
        <span>选车</span>
        <template #icon="props">
          <img :src="props.active ? car_icon.active : car_icon.inactive" />
        </template>
      </van-tabbar-item>
      <van-tabbar-item replace name="service" to="/home/service">
        <span>服务</span>
        <template #icon="props">
          <img
            :src="props.active ? service_icon.active : service_icon.inactive"
          />
        </template>
      </van-tabbar-item>
      <van-tabbar-item replace name="mine" to="/home/mine">
        <span>我的</span>
        <template #icon="props">
          <img :src="props.active ? mine_icon.active : mine_icon.inactive" />
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      active: "community",
      community_icon: {
        active: require("@/assets/tabbar/find_active.png"),
        inactive: require("@/assets/tabbar/find.png"),
      },
      shopping_icon: {
        active: require("@/assets/tabbar/shop_active.png"),
        inactive: require("@/assets/tabbar/shop.png"),
      },
      car_icon: {
        active: require("@/assets/tabbar/car_active.png"),
        inactive: require("@/assets/tabbar/car.png"),
      },
      service_icon: {
        active: require("@/assets/tabbar/service_active.png"),
        inactive: require("@/assets/tabbar/service.png"),
      },
      mine_icon: {
        active: require("@/assets/tabbar/me_active.png"),
        inactive: require("@/assets/tabbar/me.png"),
      },
    };
  },
};
</script>

<style lang="scss" scoped>
.home {
  width: 100%;
  height: 100%;
}
</style>
